package guoanmaker.operator.business.service;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import guoanmaker.operator.business.model.OperatorPromotionNew;
import guoanmaker.operator.business.repository.OperatorPromotionNewRepository;

@Service
public class OperatorPromotionNewService implements OperatorPromotionNewServiceInface {
	@Autowired
private OperatorPromotionNewRepository operatorPromotionNewRepository;
	 @PersistenceContext
		private EntityManager manager;
	@Override
	public OperatorPromotionNew saveOperatorPromotionNew(OperatorPromotionNew operatorPromotionNew) {
		// TODO Auto-generated method stub
		return operatorPromotionNewRepository.save(operatorPromotionNew);
		
	}
	
	 @Transactional
	  public void delectAllBycitycode(String citycode){
		  String jpql="delete  from OperatorPromotionNew  u where u.citycode=:citycode";
		  Query query2=manager.createQuery(jpql);//查询商品提供的服务区域
			query2.setParameter("citycode", citycode);
			query2.executeUpdate();
		  
	  }

	@Override
	public List<OperatorPromotionNew> selectOperatorPromotionNewList(String citycode) {
		// TODO Auto-generated method stub
		return operatorPromotionNewRepository.selectByOperatorPromotionNew(citycode);
	}

}
